package cn.ekuma.epos.qkorder;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dialog;
import java.awt.Frame;
import java.awt.Window;
import javax.swing.SwingUtilities;
import com.openbravo.bean.erp.Order;
import com.openbravo.data.basic.BasicException;
import com.openbravo.pos.base.AppView;
import cn.ekuma.epos.datalogic.I_DataLogicERP;

public class JOrderViewDialog extends javax.swing.JDialog {
   
    private I_DataLogicERP dlSales;
    JPanelOrderView orderView;
	
    public JOrderViewDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
    }

    private JOrderViewDialog(Dialog dialog, boolean b) {
        super(dialog,b);
    }

	
	public static JOrderViewDialog getDialog(Component parent,AppView app,I_DataLogicERP dlSales){
        Window window = SwingUtilities.getWindowAncestor(parent);
        JOrderViewDialog myMsg;
        if (window instanceof Frame) {
            myMsg = new JOrderViewDialog((Frame) window, true);
        } else {
            myMsg = new JOrderViewDialog((Dialog) window, true);
        }
        myMsg.init(app, dlSales);
        myMsg.applyComponentOrientation(parent.getComponentOrientation());
        return myMsg;
    }
	
	 private void init(AppView app,I_DataLogicERP dlSales){
		 this.dlSales = dlSales;
         initComponents();
         getContentPane().setLayout(new BorderLayout());
         orderView=new JPanelOrderView();
         orderView.init(app);
         getContentPane().add(orderView, java.awt.BorderLayout.CENTER);
    }
	 
	 public void setActiveOrder(Order order){
		 try {
			orderView.activate();
			orderView.setActiveOrder(order, null,false);
		} catch (BasicException e) {
			e.printStackTrace();
		}
		 
   	 }

	    /** This method is called from within the constructor to
	     * initialize the form.5
	     * WARNING: Do NOT modify this code. The content of this method is
	     * always regenerated by the Form Editor.
	     */
	    @SuppressWarnings("unchecked")
	    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
	    private void initComponents() {
	        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
	        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
	        setBounds((screenSize.width-800)/2, (screenSize.height-600)/2, 800, 600);
	    }// </editor-fold>//GEN-END:initComponents
}
